<template>
  <cfg-form :ref="ref" v-bind="attrs" :data="data.values"></cfg-form>
</template>

<script>
import { typeClassName } from "@/pages/config/classNameMap";
export default {
  name: "pg-form",
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref: "editView",
      onlyRead: false,
      loading: false,
    };
  },
  props: {
    data: {
      default: () => {
        return {};
      },
    },
  },
  watch: {},
  computed: {
    attrs() {
      return {
        labelWidth: 100,
        labelPosition: "right",
        cols: 2,
        columns: [
          {
            key: "sf_code",
            title: "设备编码",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
          {
            key: "sf_name",
            title: "设备名称",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
          {
            key: "sf_equipmentType",
            title: "类别名称",
            minWidth: 100,
            align: "center",
            config: {
              type: "select",
              options: this.anc.equipTypeOptions,
            },
          },
          {
            key: "equipmentPower",
            title: "设备功率(kw)",
            minWidth: 100,
            align: "center",
            config: { type: "number" },
          },
          {
            key: "bf_energyShow",
            title: "能源展示",
            minWidth: 100,
            align: "center",
            config: {
              type: "select",
              options: [
                { label: "是", value: '是' },
                { label: "否", value: '否' },
              ],
            },
          },
         
          {
            key: "sf_workshopSection",
            title: "所属工段",
            minWidth: 100,
            align: "center",
            config: {
              type: "select",
              options: [
                { label: "还原", value: "还原" },
                { label: "配碳", value: "配碳" },
                { label: "碳化破碎", value: "碳化破碎" },
                { label: "合批", value: "合批" },
                { label: "筛分", value: "筛分" },
              ],
            },
          },
          {
            key: "procedure",
            title: "默认工序",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
          {
            key: "prodSpec",
            title: "生产规格",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
          {
            key: "manufacturer",
            title: "设备厂商",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
          {
            key: "purchaseDate",
            title: "采购日期",
            minWidth: 100,
            align: "center",
            config: { type: "date" },
          },
          {
            key: "arrivalDate",
            title: "到厂日期",
            minWidth: 100,
            align: "center",
            config: { type: "date" },
          },
          {
            key: "responsible",
            title: "负责人",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
         
          {
            key: "remark",
            title: "备注",
            minWidth: 100,
            align: "center",
            config: { type: "textarea" },
          },
        ],
        rules: {
          sf_code: [{ required: true, message: "不能为空", trigger: "blur" }],
          sf_name: [{ required: true, message: "不能为空", trigger: "blur" }],
          sf_equipmentType: [
            { required: true, message: "不能为空", trigger: "blur" },
          ],
         
        },
        // onlyRead: this.onlyRead,
      };
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);
      this.jobClassObject = this.$modelObject.create(
        `${typeClassName["job"].modelType}`
      );
      this.positionClassObject = this.$modelObject.create(
        `${typeClassName["position"].modelType}`
      );
      this.anc.setOptionsByHier(
        "job",
        this.jobClassObject,
        "jobOptions",
        {
          label: "sf_name",
          value: "sf_code",
        },
        "editView"
      );
      this.anc.setOptionsByHier(
        "position",
        this.positionClassObject,
        "positionOptions",
        {
          label: "sf_name",
          value: "sf_code",
        },
        "editView"
      );
    });
  },
  methods: {
    validate(fn) {
      return this.$refs[this.ref].$refs["form"].validate((valid) => {
        if (fn) {
          return fn(valid);
        } else {
          return valid;
        }
      });
    },
    resetFields() {
      this.$refs[this.ref].$refs["form"].resetFields();
    },
  },
};
</script>
<style scoped></style>
